package cn.findviewbydream.evil.bigtoutiao.utils;

import android.content.Context;
import android.widget.Toast;

/********************************************
 * 工程名：LwCar
 * 包名：cn.findviewbydream.evil.lwcar.utils
 * 时间：17-6-13
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：toast工具
 ********************************************/
public class ToastUtil
{
    private static Context appContext;

    private static Toast toast;

    public static void init(Context appContext)
    {
        ToastUtil.appContext = appContext;
    }

    public static void show(CharSequence message)
    {
        if (toast == null)
        {
            toast = Toast.makeText(appContext, message, Toast.LENGTH_SHORT);
            toast.show();
        }
    }

    /**
     * 短时间显示Toast
     *
     * @param context
     * @param message
     */
    public static void showShort(Context context, CharSequence message)
    {
        if (toast == null)
        {
            toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
            toast.show();
        }
    }

    /**
     * 短时间显示Toast
     *
     * @param context
     * @param message
     */
    public static void showShort(Context context, int message)
    {
        if (toast == null)
        {
            toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
            toast.show();
        }
    }

    /**
     * 长时间显示Toast
     *
     * @param context
     * @param message
     */
    public static void showLong(Context context, CharSequence message)
    {
        if (toast == null)
        {
            toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
            toast.show();
        }
    }

    /**
     * 长时间显示Toast
     *
     * @param context
     * @param message
     */
    public static void showLong(Context context, int message)
    {
        if (toast == null)
        {
            toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
            toast.show();
        }
    }

    /**
     * 自定义显示Toast时间
     *
     * @param context
     * @param message
     * @param duration
     */
    public static void show(Context context, CharSequence message, int duration)
    {
        if (toast == null)
        {
            toast = Toast.makeText(context, message, duration);
            toast.show();
        }
    }

    /**
     * 自定义显示Toast时间
     *
     * @param context
     * @param message
     * @param duration
     */
    public static void show(Context context, int message, int duration)
    {
        if (toast == null)
        {
            toast = Toast.makeText(context, message, duration);
            toast.show();
        }
    }
}
